package com.ruoyi.edh.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.edh.mapper.EdhShippingTemplateMapper;
import com.ruoyi.edh.domain.EdhShippingTemplate;
import com.ruoyi.edh.service.IEdhShippingTemplateService;

/**
 * 易订货-运费模板Service业务层处理
 *
 * @author xxx
 * @date 2020-09-03
 */
@Service
public class EdhShippingTemplateServiceImpl implements IEdhShippingTemplateService
{
    @Autowired
    private EdhShippingTemplateMapper edhShippingTemplateMapper;

    /**
     * 查询易订货-运费模板
     *
     * @param id 易订货-运费模板ID
     * @return 易订货-运费模板
     */
    @Override
    public EdhShippingTemplate selectEdhShippingTemplateById(Long id)
    {
        return edhShippingTemplateMapper.selectEdhShippingTemplateById(id);
    }

    /**
     * 查询易订货-运费模板列表
     *
     * @param edhShippingTemplate 易订货-运费模板
     * @return 易订货-运费模板
     */
    @Override
    public List<EdhShippingTemplate> selectEdhShippingTemplateList(EdhShippingTemplate edhShippingTemplate)
    {
        return edhShippingTemplateMapper.selectEdhShippingTemplateList(edhShippingTemplate);
    }

    /**
     * 新增易订货-运费模板
     *
     * @param edhShippingTemplate 易订货-运费模板
     * @return 结果
     */
    @Override
    public int insertEdhShippingTemplate(EdhShippingTemplate edhShippingTemplate)
    {

        edhShippingTemplate.setCreateBy(SecurityUtils.getUserId().toString());
        edhShippingTemplate.setCreateTime(DateUtils.getNowDate());
        return edhShippingTemplateMapper.insertEdhShippingTemplate(edhShippingTemplate);
    }

    /**
     * 修改易订货-运费模板
     *
     * @param edhShippingTemplate 易订货-运费模板
     * @return 结果
     */
    @Override
    public int updateEdhShippingTemplate(EdhShippingTemplate edhShippingTemplate)
    {
        edhShippingTemplate.setUpdateBy(SecurityUtils.getUserId().toString());
        edhShippingTemplate.setUpdateTime(DateUtils.getNowDate());
        return edhShippingTemplateMapper.updateEdhShippingTemplate(edhShippingTemplate);
    }

    /**
     * 批量删除易订货-运费模板
     *
     * @param ids 需要删除的易订货-运费模板ID
     * @return 结果
     */
    @Override
    public int deleteEdhShippingTemplateByIds(Long[] ids)
    {
        return edhShippingTemplateMapper.deleteEdhShippingTemplateByIds(ids);
    }

    /**
     * 删除易订货-运费模板信息
     *
     * @param id 易订货-运费模板ID
     * @return 结果
     */
    @Override
    public int deleteEdhShippingTemplateById(Long id)
    {
        return edhShippingTemplateMapper.deleteEdhShippingTemplateById(id);
    }
    /**
     * 根据供应商id 和订单金额查找运费模版
     * @param id
     * @param shippingAmount
     * @return
     */
    @Override
    public EdhShippingTemplate selectShippingAmount(Long id, String shippingAmount) {
        return edhShippingTemplateMapper.selectShippingAmount(id,shippingAmount);
    }
}
